package com.smmisia.common.utils;

import com.smmisia.common.Result.Result;

import java.util.Arrays;

public class DbOperationHelper {
    public static boolean isSuccess(int rows) {
        return rows == 1;
    }

    public static Result handleResult(int rows, String successMsg, String failMsg) {
        return rows == 1
                ? Result.ok(successMsg)
                : Result.fail(failMsg);
    }

    // 批量操作判断
    public static boolean isAllSuccess(int... results) {
        return Arrays.stream(results).allMatch(rows -> rows == 1);
    }
}
